package com.totoro.spring.spring_demo.bean;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created by Niki on 2018/6/11 8:18
 */
@Component
public class DemoBean {

    //相当于配置文件中的init-method。当类被初始化后立即调用
    @PostConstruct
    public void init() {
        System.out.println("----------> post construct method");
    }

    public void test() {
        System.out.println("this is a demo bean");
    }

    //相当于配置文件中的destory方法，在类被销毁之前调用
    @PreDestroy
    public void destroy() {
        System.out.println("----------> pre destroy method");
    }
}
